
package com.seekting.study;

public class Base64Study {

    public static void main(String[] args) {
        String t = "xl;jdklfkjsajkfds;afda";
        byte[] byte1 = Base64.decode(t, Base64.DEFAULT);
        byte[] sub = getSubBtyes(1024, byte1);
        String str = Base64.encodeToString(sub, Base64.DEFAULT);
        System.out.println(str);
    }

    private static byte[] getSubBtyes(int maxLength, byte[] input) {
        byte[] result;
        if (input.length > maxLength) {
            result = new byte[maxLength];
            for (int i = 0; i < maxLength; i++) {
                result[i] = input[i];
            }
        } else {
            result = input;
        }
        return result;
    }
}
